var appuserlist = {
		
		curPage : 1,
		pageSize : 20,
		
		initPage : function(){
			appuserlist.initBtn();
			appuserlist.getDatalist(0);
		},
		
		initBtn : function(){
			$("#addBtn").click(function(){
				appuserlist.addDevice();
			});
			$("#qryBtn").click(function(){
				appuserlist.getDatalist(0);
			});
		},
		
		getDatalist : function(pageIndex){
			$('#appuserlist').html('<tr><td colspan="10"  style="text-align:center;">正在查询,请稍后...</td></tr>');
			$('#appuserlistpage').html("");
			pageIndex=(pageIndex==null)? 0:pageIndex;
			var params = {};
			params['curPage'] = pageIndex + 1;
			params['pageSize'] = appuserlist.pageSize;
			params['userType'] = "1";
			params['account'] = $("#nickName").val();
			usermanager.getUserList(params, appuserlist.getappuserlist_Succ, appuserlist.getappuserlist_error);
			appuserlist.curPage = pageIndex + 1;
		},
		
		getappuserlist_Succ : function(data){
			if(data && data.retCode == 0){
				var _html = '';
				if(data.data && data.data.length > 0){
					for(var key in data.data){
						var item = data.data[key];
						_html += '<tr><td class="tal"> '+((parseInt(appuserlist.curPage)-1)*appuserlist.pageSize + (parseInt(key)+1))+'</td>';
						_html += '<td class="tal">'+item.account+'</td>';
						_html += '<td class="tal">'+item.email+'</td><td>'+item.address+'</td><td>'+item.sex+'</td><td>'+item.age+'</td><td>'+item.createTime+'</td>';
						_html += '<td> ';
						_html += '<a class="mr-5" href=\"javascript:void(0);\" onclick="appuserlist.singleDel('+item.userId+')">删除</a></td></tr>';
					}
					$('#appuserlist').html(_html);
					if(data.page){
						util.paginationPage($('#appuserlistpage'), data.page.totalPage, parseInt(data.page.curPage-1), appuserlist.getappuserlist,true);
					}
				}else{
					$('#appuserlist').html('<tr  align="center"><td colspan=10>暂无数据.</td></tr>');
					$('#appuserlistpage').html("");
				}
			}else{
				$.dialog( {
					title : '错误',
					icon : 'error',
					content : '获取错误！',
					time : 3
				});
			}
		},
		
		getappuserlist_error:function(data){
			window.location.reload();
		},
		
		
		addDevice : function(){
			layer.open({
				type:2,
				content:util.webpath+'user/addUser.html'
			});
//			util.loadContent(util.webpath+'user/addUser.html','contentDiv',{},function(){
//				adduser.initPage();
//			});
		},

		editDevice : function(id){
			util.loadContent(util.webpath+'user/addUser.html','contentDiv',{},function(){
				adduser.id=id;
				adduser.initPage();
			});
		},
		
		singleDel:function(userId){
			layer.confirm(language.confirmdelete[mainIndex.languageType], {
				  btn: [language.ok[mainIndex.languageType],language.cancel[mainIndex.languageType]] //按钮
				}, function(){
					usermanager.delUser({"userId":userId},function(){
						layer.msg(language.operatorSuccess[mainIndex.languageType], {icon: 1});
						appuserlist.getDatalist(0);
					});
				});
		}
		
		
};
appuserlist.initPage();
